package io.renren.com.qywt.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.commons.mybatis.service.impl.CrudServiceImpl;
import io.renren.com.qywt.dao.AftersaleInventoryDao;
import io.renren.com.qywt.dto.AftersaleInventoryDTO;
import io.renren.com.qywt.entity.AftersaleInventoryEntity;
import io.renren.com.qywt.service.AftersaleInventoryService;
import io.renren.commons.security.context.TenantContext;
import io.renren.commons.security.user.SecurityUser;
import io.renren.commons.tools.utils.ConvertUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 进销存表
 *
 * @author jiaohj 15110414840@139.com
 * @since 3.0 2022-09-02
 */
@Service
public class AftersaleInventoryServiceImpl extends CrudServiceImpl<AftersaleInventoryDao, AftersaleInventoryEntity, AftersaleInventoryDTO> implements AftersaleInventoryService {

    @Override
    public QueryWrapper<AftersaleInventoryEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<AftersaleInventoryEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("del_flag", params.get("del_flag"));
        wrapper.isNull("sku_id");
        return wrapper;
    }

    @Override
    public List<AftersaleInventoryDTO> getProdNum() {
        return ConvertUtils.sourceToTarget(baseDao.getProdNum(),AftersaleInventoryDTO.class);
    }

    @Override
    public List<AftersaleInventoryDTO> getSkuInfo(String productNo, String itemName) {
        return ConvertUtils.sourceToTarget(baseDao.getSkuInfo(productNo,itemName),AftersaleInventoryDTO.class)   ;
    }

    @Override
    public List<AftersaleInventoryDTO> getNotExistData(String collectDate) {
        return ConvertUtils.sourceToTarget(baseDao.getNotExistData(collectDate),AftersaleInventoryDTO.class);
    }

    @Override
    public List<AftersaleInventoryDTO> getExistData(String collectDate) {
        List<AftersaleInventoryEntity> list=baseDao.getExistData(collectDate);
        if(CollectionUtil.isNotEmpty(list)){
            return ConvertUtils.sourceToTarget(list,AftersaleInventoryDTO.class);
        }
        return null;
    }
}